import numpy as np

# 定义dtype
dt_map = np.dtype(
    [
        ("name", "S16"),
        ("hight", np.uint32),
        ("weight", np.uint32),
        ("age", np.uint32),
        ("id", np.uint32),
    ]
)

# 创建示例数据
data = np.array(
    [
        ("lili", 160, 50, 18, 1),
        ("lucy", 165, 55, 19, 2),
        ("tom", 180, 70, 20, 3),
        ("jerry", 175, 65, 21, 4),
        ("lucy", 165, 70, 22, 5),
    ],
    dtype=dt_map,
)

# 通过id搜索
idx = np.where(data["id"] == 2)
print(f"id==2 的位置为：{idx[0].item()}")

# 组合搜索: id,name
idx = np.where((data["id"] == 3) & (data["name"] == b"tom"))
print(f"id==2 and name==lucy 的位置为：{idx[0].item()}")
